In contrast AF systems that are widely used in electronic cameras as autofocus methods, generally, images of a subject are picked up while a focus lens that is included in a photographing optical system and that acts on focus adjustment is moved, and then image signals of the subject are generated. Luminance signals are generated from the generated image signals, and high-frequency components are extracted from the luminance signals. Then, based on the extracted high-frequency components, focus evaluation values that are used to identify an in-focus position are calculated.
The focus lens is driven within a predetermined range, for example, between an infinity position and a close-up position or closest focusing distance position, and the focus evaluation values are calculated at each of a plurality of positions within that range. Then, the position where the focus evaluation value is at the maximum is identified as the in-focus position of the focus lens.
In contrast AF systems, the in-focus position is set to a position of the focus lens or the photographing optical system where the focus evaluation value is at the maximum. However, since there is an upper limit to the focus evaluation value due to configurational limitations (e.g., the number of bits of data in the focus evaluation value) of electronic cameras, an overflow of a calculated focus evaluation value may occur. When any focus evaluation value overflows, the maximum focus evaluation value is not properly identified, and so the focus lens or the photographing optical system may be placed in a false in-focus position.
On the other hand, when each of the focus evaluation values calculated between the infinity position and the close-up position is extremely small, significant differences between the focus evaluation values cannot be obtained, and so the in-focus position may be improperly set.
The present invention provides an electronic apparatus having a camera function, the electronic apparatus realizing high-precision autofocus by performing control so that an overflow of a calculated focus evaluation value is avoided or a focus evaluation value that is large enough to set the in-focus position is calculated.